package com.base.web.model.master.auth;

import java.util.Objects;

/**
 * Created with IntelliJ IDEA.
 * Description: 页面多级菜单显示类
 *
 * @Author: rentie
 * @Date: 2018/7/9 16:47
 */
public class MenuTree implements Comparable<MenuTree>  {
    /**
     * 菜单显示的值
     */
    private String title;

    /**
     * 菜单对应的隐藏值
     */
    private String value;

    /**
     * 图标
     */
    private String icon;

    /**
     * 排序
     */
    private Integer order;

    /**
     * 子菜单数据
     */
    private Object data;

    public MenuTree() {
    }

    public MenuTree(String title, String value) {
        this.title = title;
        this.value = value;
    }

    public MenuTree(String title, String value, String icon) {
        this.title = title;
        this.value = value;
        this.icon = icon;
    }

    public MenuTree(String title, String value, String icon, Integer order) {
        this.title = title;
        this.value = value;
        this.icon = icon;
        this.order = order;
    }

    public String getIcon() {
        return icon;
    }

    public void setIcon(String icon) {
        this.icon = icon;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public Integer getOrder() {
        return order;
    }

    public void setOrder(Integer order) {
        this.order = order;
    }

    @Override
    public String toString() {
        return "MenuTree{" +
                "title='" + title + '\'' +
                ", value='" + value + '\'' +
                ", icon='" + icon + '\'' +
                ", order=" + order +
                ", data=" + data +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        MenuTree menuTree = (MenuTree) o;
        return Objects.equals(title, menuTree.title) &&
                Objects.equals(value, menuTree.value) &&
                Objects.equals(icon, menuTree.icon) &&
                Objects.equals(order, menuTree.order) &&
                Objects.equals(data, menuTree.data);
    }

    @Override
    public int hashCode() {

        return Objects.hash(title, value, icon, order, data);
    }


    @Override
    public int compareTo(MenuTree m) {
        if (m.order == this.order) {
            return 0;
        } else if (this.order > m.order) {
            return 1;
        } else
            return -1;
    }
}